package com.btrace;

import com.sun.btrace.annotations.*;

import static com.sun.btrace.BTraceUtils.Strings.str;
import static com.sun.btrace.BTraceUtils.println;
import static com.sun.btrace.BTraceUtils.timeMillis;

/**
 * @author: csh
 * @Date: 2022/6/25 16:29
 * @Description:监控耗时
 */
@BTrace
public class TlsBtrace {




    @TLS
    private static long startTime = 0;
    /**
     *
     * 功能描述: 
     *
     * @param: /.+/ :监控任意类
     * @return: 
     * @auther: csh
     * @date: 2022/6/25 4:36 下午
     */
    @OnMethod(clazz = "com.btrace.BtraceStudy", method="readHong")
    public static void startMethod(){
        startTime = timeMillis();
    }

    @OnMethod(clazz = "com.btrace.BtraceStudy", method="readHong", location=@Location(Kind.RETURN))
    public static void endMethod(@ProbeClassName String pcm, @ProbeMethodName String pmn) {
        println(pcm + "." + pmn + " [Time taken: " + str(timeMillis() - startTime) + "ms]");
    }
    
    


}
